package cn.wubo.redis.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundListOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/redisBound")
public class RedisBoundController {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @RequestMapping(value = "/testBoundKey", method = RequestMethod.GET)
    public List<String> testBoundKey(String key) {
        BoundListOperations operations = stringRedisTemplate.boundListOps(key);
        operations.rightPush("a");
        operations.rightPush("b");
        return (List<String>)operations.range(0,stringRedisTemplate.opsForList().size(key));
    }
}
